def setUp(self): """ Set up the test """ test_utils.setup_test_storage() clear_index.Command().handle(using=[ settings.TEST_MODE_NAME, ], interactive=False)
def _run_custom_test_db_setup(): """ Runs the custom test DB setup logic which is required in META-SHARE. """ # from now on, redirect any search index access to the test index MetashareRouter.in_test_mode = True # clear the test index clear_index.Command().handle(interactive=False, using=[ settings.TEST_MODE_NAME, ])
def setUp(self): """ Set up the view """ test_utils.setup_test_storage() clear_index.Command().handle(interactive=False, using=[ settings.TEST_MODE_NAME, ]) normaluser = create_user('normaluser', '*****@*****.**', 'secret') normaluser.save() # create an groups used to get the proper results Group.objects.create(name='ecmembers') Group.objects.create(name='elrcReviewers')
def setUp(self): super(TestMatchEvents, self).setUp() haystack.connections.reload('default') FacebookCustomUser.objects.all().delete() self.user = FacebookCustomUser.objects. \ create_user(username='******', facebook_id=1234567, first_name='Andrii', password='******', gender='m', date_of_birth=date(1989, 5, 20)) self.user1 = FacebookCustomUser.objects. \ create_user(username='******', facebook_id=12345671, first_name='Sasa', gender='m', password='******', date_of_birth=date(1979, 1, 9)) user_location = UserLocation.objects.create( user=self.user, position=[-87.627696, 41.880745]) user_location1 = UserLocation.objects.create( user=self.user1, position=[-87.627696, 41.880745]) self.subject = Subject.objects.create(description='learning django') self.subject2 = Subject.objects.create(description='learn python') clear_index.Command().handle(interactive=False) rebuild_index.Command().handle(interactive=False) self.neo = NeoFourJ() self.neo.graph.delete_all()
def setup(self): # Permission handler self.perm_handler = PermissionHandler() # Set up the following forum tree: # # top_level_cat # forum_1 # forum_2 # forum_2_child_1 # top_level_forum_1 # top_level_forum_2 # sub_cat # sub_sub_forum # top_level_forum_3 # forum_3 # forum_3_child_1 # forum_3_child_1_1 # deep_forum # last_forum # self.top_level_cat = create_category_forum() self.forum_1 = create_forum(parent=self.top_level_cat) self.forum_2 = create_forum(parent=self.top_level_cat) self.forum_2_child_1 = create_forum(parent=self.forum_2) self.top_level_forum_1 = create_forum() self.top_level_forum_2 = create_forum() self.sub_cat = create_category_forum(parent=self.top_level_forum_2) self.sub_sub_forum = create_forum(parent=self.sub_cat) self.top_level_forum_3 = create_forum() self.forum_3 = create_forum(parent=self.top_level_forum_3) self.forum_3_child_1 = create_forum(parent=self.forum_3) self.forum_3_child_1_1 = create_forum(parent=self.forum_3_child_1) self.deep_forum = create_forum(parent=self.forum_3_child_1_1) self.last_forum = create_forum() # Set up a topic and some posts self.topic_1 = create_topic(forum=self.forum_1, poster=self.user) self.post_1 = PostFactory.create(topic=self.topic_1, poster=self.user) self.topic_2 = create_topic(forum=self.forum_2, poster=self.user) self.post_2 = PostFactory.create(topic=self.topic_2, poster=self.user) self.topic_3 = create_topic(forum=self.forum_2_child_1, poster=self.user) self.post_3 = PostFactory.create(topic=self.topic_3, poster=self.user) # Assign some permissions assign_perm('can_read_forum', self.user, self.top_level_cat) assign_perm('can_read_forum', self.user, self.forum_1) assign_perm('can_read_forum', self.user, self.forum_2) assign_perm('can_read_forum', self.user, self.forum_2_child_1) assign_perm('can_read_forum', self.user, self.top_level_forum_1) self.sqs = SearchQuerySet() rebuild_index.Command().handle(interactive=False, verbosity=-1) yield # teardown # -- clear_index.Command().handle(interactive=False, verbosity=-1)
def tearDown(self): # delete dummy self.dummy.delete() # clear index clear_index.Command().handle(interactive=False)
def setUp(self): super(TestMatchQuerySet, self).setUp() haystack.connections.reload('default') Goal.objects.all().delete() Offer.objects.all().delete() Subject.objects.all().delete() FacebookCustomUser.objects.all().delete() photo = SimpleUploadedFile(name='test_image.jpg', content='test') self.user = FacebookCustomUser.objects.\ create_user(username='******', facebook_id=1234567, first_name='Andrii', password='******', gender='m', date_of_birth=date(1989, 5, 20), image=photo) self.user1 = FacebookCustomUser.objects.\ create_user(username='******', facebook_id=12345671, first_name='Sasa', gender='m', password='******', date_of_birth=date(1979, 1, 9), image=photo) self.user2 = FacebookCustomUser.objects. \ create_user(username='******', facebook_id=12345672, first_name='Ira', gender='f', password='******', date_of_birth=date(1969, 1, 9), image=photo) self.user3 = FacebookCustomUser.objects. \ create_user(username='******', facebook_id=12345676, first_name='Natali', gender='f', password='******', date_of_birth=date(1959, 1, 9), image=photo) self.user4 = FacebookCustomUser.objects. \ create_user(username='******', facebook_id=12345675, first_name='Tati', gender='f', password='******', date_of_birth=date(1949, 1, 9), image=photo) self.user5 = FacebookCustomUser.objects. \ create_user(username='******', facebook_id=12345674, first_name='Ken', gender='m', password='******', date_of_birth=date(1939, 1, 9), image=photo) user_location = UserLocation.objects.create( user=self.user, position=[-87.627696, 41.880745]) user_location1 = UserLocation.objects.create( user=self.user1, position=[60.627675, 21.881925]) user_location2 = UserLocation.objects.create( user=self.user2, position=[-87.6281729688, 41.881849562]) user_location3 = UserLocation.objects.create( user=self.user5, position=[-87.62839, 41.88206]) user_location4 = UserLocation.objects.create( user=self.user4, position=[-87.6269801114, 41.8814058757]) user_location5 = UserLocation.objects.create(user=self.user3, position=[38.53, 77.02]) self.subject = Subject.objects.create(description='learning django') self.subject2 = Subject.objects.create(description='learn python') self.subject3 = Subject.objects.create(description='teach erlang') self.subject4 = Subject.objects.create(description='teach javascript') self.subject5 = Subject.objects.create(description='teach django') self.subject6 = Subject.objects.create(description='teach python') self.subject7 = Subject.objects.create(description='learn erlang') self.subject8 = Subject.objects.create(description='learn javascript') self.subject9 = Subject.objects.\ create(description='django under the hood') self.subject10 = Subject.objects.\ create(description='learn kiteboarding and foxes') self.subject11 = Subject.objects.\ create(description='like a kiteboard and fox') self.subject12 = Subject.objects. \ create(description='baby') self.subject13 = Subject.objects. \ create(description='child') self.subject14 = Subject.objects. \ create(description='hire a dog sitter') self.subject16 = Subject.objects. \ create(description='play with dogs') self.subject15 = Subject.objects. \ create(description='learn to code django python') self.i_subject = InterestSubject.objects.\ create(description='teach django') self.i_subject1 = InterestSubject.objects. \ create(description='learn django') self.i_subject2 = InterestSubject.objects. \ create(description='teach python') self.i_subject3 = InterestSubject.objects. \ create(description='learn python') self.i_subject4 = InterestSubject.objects. \ create(description='kiteboarding') StopWords.objects.create(word='learn') StopWords.objects.create(word=u'and') StopWords.objects.create(word=u'teach') StopWords.objects.create(word=u'to') clear_index.Command().handle(interactive=False) rebuild_index.Command().handle(interactive=False) self.neo = NeoFourJ() self.neo.graph.delete_all()
def tearDownClass(cls): clear_index.Command().handle(using=['test_index'], interactive=False, verbosity=0) super().tearDownClass()