Ejemplo n.º 1
0
    def test_fixture_context_path_comes_back_on_leave(self):

        with fixtures.Fixture():
            self.assertTrue(os.path.exists('./_trial_temp'))

        self.assertTrue(not os.path.exists('./_trial_temp'))
        self.assertEqual(os.path.split(os.getcwd())[1], '_trial_temp')
Ejemplo n.º 2
0
    def test_fixture_context_model_database_come_back_on_leave(self):

        with fixtures.Fixture(model=Model) as fxt:
            database = fxt._original_databases[id(Model)]
            self.assertIsInstance(fxt._model.database, FakeTesttableDatabase)
            self.assertIs(fxt._model.database, Model.database)

        self.assertIs(Model.database, database)
Ejemplo n.º 3
0
    def test_fixture_context_model_iterable_works(self):

        with fixtures.Fixture(model=(DummyModel, DummyModelFive)) as fxt:
            self.assertIsInstance(fxt._model[0].database,
                                  FakeTesttableDatabase)
            self.assertIsInstance(fxt._model[1].database,
                                  FakeTesttableDatabase)
            self.assertIs(fxt._model[0].database, DummyModel.database)
            self.assertIs(fxt._model[1].database, DummyModelFive.database)
Ejemplo n.º 4
0
 def test_fixture_context_raises_fixture_error_on_wrong_path(self):
     os.chdir('../')
     try:
         with fixtures.Fixture():
             pass
     except fixtures.FixtureError as error:
         self.assertEqual(error[0],
                          'Fixture context must be used in tests only')
         os.chdir('_trial_temp')
Ejemplo n.º 5
0
    def test_fixture_context_model_iterable_comes_back_on_leave(self):

        database = DummyModel.database
        with fixtures.Fixture(model=(DummyModel, DummyModelFive)) as fxt:
            self.assertIsInstance(fxt._model[0].database,
                                  FakeTesttableDatabase)
            self.assertIsInstance(fxt._model[1].database,
                                  FakeTesttableDatabase)
            self.assertIs(fxt._model[0].database, DummyModel.database)
            self.assertIs(fxt._model[1].database, DummyModelFive.database)

        self.assertIs(DummyModel.database, database)
Ejemplo n.º 6
0
 def test_fixture_context_returns_himself_when_as_is_used(self):
     with fixtures.Fixture() as fxt:
         self.assertIsInstance(fxt, fixtures.Fixture)
Ejemplo n.º 7
0
    def setUp(self):

        self._testable_database = fixtures.TestableDatabase
        fixtures.TestableDatabase = FakeTesttableDatabase
        self.currdir = os.getcwd()
        self.fixture = fixtures.Fixture()
Ejemplo n.º 8
0
    def test_fixture_context_model_engine_is_set_if_given(self):

        with fixtures.Fixture(model=Model,
                              engine=fixtures.ENGINE.NATIVE) as fxt:
            self.assertIs(fxt._model.database.engine, fixtures.ENGINE.NATIVE)
Ejemplo n.º 9
0
    def test_fixture_context_model_prepate_for_test_if_given(self):

        with fixtures.Fixture(model=Model) as fxt:
            self.assertIsInstance(fxt._model.database, FakeTesttableDatabase)
            self.assertIs(fxt._model.database, Model.database)
Ejemplo n.º 10
0
    def test_fixture_context_uses_path_if_given(self):

        with fixtures.Fixture(path='../mamba/test/dummy_app'):
            self.assertEqual(os.path.split(os.getcwd())[1], 'dummy_app')
Ejemplo n.º 11
0
    def test_fixture_context_defaults_to_inmediate_directory(self):

        with fixtures.Fixture():
            self.assertTrue(fixtures.os.path.exists('./_trial_temp'))