Example #1
0
class TestJSONFileLoader(BaseEnvVar):
    def setUp(self):
        super(TestJSONFileLoader, self).setUp()
        self.data_path = os.path.join(os.path.dirname(__file__), 'data')
        self.file_loader = JSONFileLoader()
        self.valid_file_path = os.path.join(self.data_path, 'foo')

    def test_load_file(self):
        data = self.file_loader.load_file(self.valid_file_path)
        self.assertEqual(len(data), 3)
        self.assertTrue('test_key_1' in data)

    def test_load_json_file_does_not_exist_returns_none(self):
        # None is used to indicate that the loader could not find a
        # file to load.
        self.assertIsNone(self.file_loader.load_file('fooasdfasdfasdf'))

    def test_file_exists_check(self):
        self.assertTrue(self.file_loader.exists(self.valid_file_path))

    def test_file_does_not_exist_returns_false(self):
        self.assertFalse(self.file_loader.exists(
            os.path.join(self.data_path, 'does', 'not', 'exist')))

    def test_file_with_non_ascii(self):
        try:
            filename = os.path.join(self.data_path, 'non_ascii')
            self.assertTrue(self.file_loader.load_file(filename) is not None)
        except UnicodeDecodeError:
            self.fail('Fail to handle data file with non-ascii characters')
Example #2
0
class TestJSONFileLoader(BaseEnvVar):
    def setUp(self):
        super(TestJSONFileLoader, self).setUp()
        self.data_path = os.path.join(os.path.dirname(__file__), 'data')
        self.file_loader = JSONFileLoader()
        self.valid_file_path = os.path.join(self.data_path, 'foo')

    def test_load_file(self):
        data = self.file_loader.load_file(self.valid_file_path)
        self.assertEqual(len(data), 3)
        self.assertTrue('test_key_1' in data)

    def test_load_json_file_does_not_exist_returns_none(self):
        # None is used to indicate that the loader could not find a
        # file to load.
        self.assertIsNone(self.file_loader.load_file('fooasdfasdfasdf'))

    def test_file_exists_check(self):
        self.assertTrue(self.file_loader.exists(self.valid_file_path))

    def test_file_does_not_exist_returns_false(self):
        self.assertFalse(
            self.file_loader.exists(
                os.path.join(self.data_path, 'does', 'not', 'exist')))

    def test_file_with_non_ascii(self):
        try:
            filename = os.path.join(self.data_path, 'non_ascii')
            self.assertTrue(self.file_loader.load_file(filename) is not None)
        except UnicodeDecodeError:
            self.fail('Fail to handle data file with non-ascii characters')
Example #3
0
class JSONFileLoaderTestCase(BaseEnvVar):
    def setUp(self):
        super(JSONFileLoaderTestCase, self).setUp()
        self.data_path = os.path.join(os.path.dirname(__file__), 'data')
        self.file_loader = JSONFileLoader()

    def test_load_file(self):
        data = self.file_loader.load_file(
            os.path.join(self.data_path, 'foo.json'))
        self.assertEqual(len(data), 3)
        self.assertTrue('test_key_1' in data)
Example #4
0
class JSONFileLoaderTestCase(BaseEnvVar):
    def setUp(self):
        super(JSONFileLoaderTestCase, self).setUp()
        self.data_path = os.path.join(os.path.dirname(__file__), 'data')
        self.file_loader = JSONFileLoader()

    def test_load_file(self):
        data = self.file_loader.load_file(
            os.path.join(self.data_path, 'foo.json')
        )
        self.assertEqual(len(data), 3)
        self.assertTrue('test_key_1' in data)
Example #5
0
class TestJSONFileLoader(BaseEnvVar):
    def setUp(self):
        super(TestJSONFileLoader, self).setUp()
        self.data_path = os.path.join(os.path.dirname(__file__), 'data')
        self.file_loader = JSONFileLoader()
        self.valid_file_path = os.path.join(self.data_path, 'foo')

    def test_load_file(self):
        data = self.file_loader.load_file(self.valid_file_path)
        self.assertEqual(len(data), 3)
        self.assertTrue('test_key_1' in data)

    def test_load_json_file_does_not_exist_returns_none(self):
        # None is used to indicate that the loader could not find a
        # file to load.
        self.assertIsNone(self.file_loader.load_file('fooasdfasdfasdf'))

    def test_file_exists_check(self):
        self.assertTrue(self.file_loader.exists(self.valid_file_path))

    def test_file_does_not_exist_returns_false(self):
        self.assertFalse(self.file_loader.exists(
            os.path.join(self.data_path, 'does', 'not', 'exist')))
Example #6
0
class TestJSONFileLoader(BaseEnvVar):
    def setUp(self):
        super(TestJSONFileLoader, self).setUp()
        self.data_path = os.path.join(os.path.dirname(__file__), 'data')
        self.file_loader = JSONFileLoader()
        self.valid_file_path = os.path.join(self.data_path, 'foo')

    def test_load_file(self):
        data = self.file_loader.load_file(self.valid_file_path)
        self.assertEqual(len(data), 3)
        self.assertTrue('test_key_1' in data)

    def test_load_json_file_does_not_exist_returns_none(self):
        # None is used to indicate that the loader could not find a
        # file to load.
        self.assertIsNone(self.file_loader.load_file('fooasdfasdfasdf'))

    def test_file_exists_check(self):
        self.assertTrue(self.file_loader.exists(self.valid_file_path))

    def test_file_does_not_exist_returns_false(self):
        self.assertFalse(self.file_loader.exists(
            os.path.join(self.data_path, 'does', 'not', 'exist')))
Example #7
0
 def setUp(self):
     super(TestJSONFileLoader, self).setUp()
     self.data_path = os.path.join(os.path.dirname(__file__), 'data')
     self.file_loader = JSONFileLoader()
     self.valid_file_path = os.path.join(self.data_path, 'foo')
Example #8
0
 def setUp(self):
     super(TestJSONFileLoader, self).setUp()
     self.data_path = os.path.join(os.path.dirname(__file__), 'data')
     self.file_loader = JSONFileLoader()
     self.valid_file_path = os.path.join(self.data_path, 'foo')
Example #9
0
 def setUp(self):
     super(JSONFileLoaderTestCase, self).setUp()
     self.data_path = os.path.join(os.path.dirname(__file__), 'data')
     self.file_loader = JSONFileLoader()
Example #10
0
 def setUp(self):
     super(JSONFileLoaderTestCase, self).setUp()
     self.data_path = os.path.join(os.path.dirname(__file__), 'data')
     self.file_loader = JSONFileLoader()