def test_add(self): path = "/etc/nginx/sites-enabled/example.com.conf" add_static("example.com") self.assertFalse(os.path.exists(path)) enable("example.com") self.assertTrue(os.path.exists(path))
def test_short_and(self): conf = "/etc/nginx/sites-available/a.conf" html = "/html/a/index.html" self.assertFalse(os.path.exists(conf)) self.assertFalse(os.path.exists(html)) add_static("a") self.assertTrue(os.path.exists(conf)) self.assertTrue(os.path.exists(html))
def test_long_and(self): conf = "/etc/nginx/sites-available/asonetuhasonetuhasonetuh.conf" html = "/html/asonetuhasonetuhasonetuh/index.html" self.assertFalse(os.path.exists(conf)) self.assertFalse(os.path.exists(html)) add_static("asonetuhasonetuhasonetuh") self.assertTrue(os.path.exists(conf)) self.assertTrue(os.path.exists(html))
def test_already_exists(self): conf = "/etc/nginx/sites-available/a.conf" html = "/html/a/index.html" self.assertFalse(os.path.exists(conf)) self.assertFalse(os.path.exists(html)) self.assertEqual(add_static("a"), "OK") self.assertEqual(add_static("a"), "ERROR") self.assertTrue(os.path.exists(conf)) self.assertTrue(os.path.exists(html))
def test_add(self): conf = "/etc/nginx/sites-available/example.com.conf" html = "/html/example.com/index.html" self.assertFalse(os.path.exists(conf)) self.assertFalse(os.path.exists(html)) add_static("example.com") self.assertTrue(os.path.exists(conf)) self.assertTrue(os.path.exists(html))
def test_two_add(self): conf1 = "/etc/nginx/sites-available/example.com.conf" html1 = "/html/example.com/index.html" conf2 = "/etc/nginx/sites-available/test.com.conf" html2 = "/html/test.com/index.html" self.assertFalse(os.path.exists(conf1)) self.assertFalse(os.path.exists(html1)) self.assertFalse(os.path.exists(conf2)) self.assertFalse(os.path.exists(html2)) add_static("example.com") add_static("test.com") self.assertTrue(os.path.exists(conf1)) self.assertTrue(os.path.exists(html1)) self.assertTrue(os.path.exists(conf2)) self.assertTrue(os.path.exists(html2))
def test_short_add(self): path = "/etc/nginx/sites-enabled/a.conf" add_static("a") self.assertFalse(os.path.exists(path)) enable("a") self.assertTrue(os.path.exists(path))
def test_long_add(self): path = "/etc/nginx/sites-enabled/asonetuhasonetuhasonetuh.conf" add_static("asonetuhasonetuhasonetuh") self.assertFalse(os.path.exists(path)) enable("asonetuhasonetuhasonetuh") self.assertTrue(os.path.exists(path))