Ejemplo n.º 1
0
    def test_json_file_has_correct_properties(self):
        with self.assertRaises(KeyError):
            bad_property_template = Template(self.test_json_files["bad_property_json_file"])
            bad_property_template.read()

        with self.assertRaises(ValueError):
            missing_property_template = Template(self.test_json_files["missing_property_json_file"])
            missing_property_template.read()

        valid_template = Template(self.test_json_files["valid_json_file"])
        valid_template.read()

        for json_template_property in self.json_template_properties:
            self.assertIsNotNone(valid_template.__dict__[json_template_property])
Ejemplo n.º 2
0
    def test_valid_json_format(self):
        with self.assertRaises(ValueError):
            blank_template = Template(self.test_json_files["blank_json_file"])
            blank_template.read()

        with self.assertRaises(ValueError):
            invalid_template = Template(self.test_json_files["invalid_json_file"])
            invalid_template.read()

        try:
            valid_template = Template(self.test_json_files["valid_json_file"])
            valid_template.read()
        except ValueError:
            self.fail("valid_json_file not valid JSON")
Ejemplo n.º 3
0
    def test_json_file_exists(self):
        with self.assertRaises(IOError):
            missing_template = Template(
                self.test_json_files["missing_json_file"])
            missing_template.read()

        try:
            valid_template = Template(self.test_json_files["valid_json_file"])
            valid_template.read()
        except IOError:
            self.fail("valid_json_file not found: %s" %
                      self.test_json_files["valid_json_file"])
Ejemplo n.º 4
0
    def test_json_file_exists(self):
        with self.assertRaises(IOError):
            missing_template = Template(self.test_json_files["missing_json_file"])
            missing_template.read()

        try:
            valid_template = Template(self.test_json_files["valid_json_file"])
            valid_template.read()
        except IOError:
            self.fail("valid_json_file not found: %s" % self.test_json_files["valid_json_file"])
Ejemplo n.º 5
0
    def test_for_correct_values(self):
        valid_template = Template(self.test_json_files["valid_json_file"])
        valid_template.read()

        for key, value in self.json_values.iteritems():
            self.assertEqual(valid_template.__dict__[key], value)
Ejemplo n.º 6
0
    def test_json_file_has_correct_properties(self):
        with self.assertRaises(KeyError):
            bad_property_template = Template(
                self.test_json_files["bad_property_json_file"])
            bad_property_template.read()

        with self.assertRaises(ValueError):
            missing_property_template = Template(
                self.test_json_files["missing_property_json_file"])
            missing_property_template.read()

        valid_template = Template(self.test_json_files["valid_json_file"])
        valid_template.read()

        for json_template_property in self.json_template_properties:
            self.assertIsNotNone(
                valid_template.__dict__[json_template_property])
Ejemplo n.º 7
0
    def test_valid_json_format(self):
        with self.assertRaises(ValueError):
            blank_template = Template(self.test_json_files["blank_json_file"])
            blank_template.read()

        with self.assertRaises(ValueError):
            invalid_template = Template(
                self.test_json_files["invalid_json_file"])
            invalid_template.read()

        try:
            valid_template = Template(self.test_json_files["valid_json_file"])
            valid_template.read()
        except ValueError:
            self.fail("valid_json_file not valid JSON")
Ejemplo n.º 8
0
    def test_for_correct_values(self):
        valid_template = Template(self.test_json_files["valid_json_file"])
        valid_template.read()

        for key, value in self.json_values.iteritems():
            self.assertEqual(valid_template.__dict__[key], value)