Esempio n. 1
0
    def test_crt_s_md(self):
        f = j(dm, "f.bmp")
        cid(f)
        put("csmd(f)", csmd(f, True))
        de(f)

        f = j(dm, "f.jpeg")
        cid(f)
        put("csmd(f)", csmd(f, True))
        de(f)

        f = j(dm, "f.jpg")
        cid(f)
        put("csmd(f)", csmd(f, True))
        de(f)

        f = j(dm, "f.png")
        cid(f)
        put("csmd(f)", csmd(f, True))
        de(f)

        f = j(dm, "f.f")
        cr(f, False)
        put("csmd(f)", csmd(f, False))
        de(f)

        f = j(dm, "f")
        cr(f, False)
        with self.assertRaises(EX_NFE):
            csmd(f, False)
        de(f)
Esempio n. 2
0
    def test_get_img_dim_w(self):
        f = j(dm, "f.bmp")
        cid(f)
        put("gidw(f)", gidw(f))
        de(f)

        f = j(dm, "f.jpeg")
        cid(f)
        put("gidw(f)", gidw(f))
        de(f)

        f = j(dm, "f.jpg")
        cid(f)
        put("gidw(f)", gidw(f))
        de(f)

        f = j(dm, "f.png")
        cid(f)
        put("gidw(f)", gidw(f))
        de(f)

        f = n("./f.f")
        with self.assertRaises(EX_NAP):
            gidw(f)

        f = j(dm, "f.bmp")
        with self.assertRaises(EX_NEF):
            gidw(f)

        f = j(dm, "f.f")
        cr(f, False)
        with self.assertRaises(EX_NIMG):
            gidw(f)
        de(f)
Esempio n. 3
0
    def test_crt_md(self):
        f = j(dm, "f.md")
        self.assertTrue(crm(f))
        de(f)

        f = n("./f.md")
        with self.assertRaises(EX_NAP):
            crm(f)

        f = j(dm, "f.f")
        cr(f, False)
        with self.assertRaises(EX_NEMD):
            crm(f)
        de(f)
Esempio n. 4
0
    def test_wrt_md_b(self):
        f = j(dm, "f.md")
        cr(f, False)
        self.assertTrue(wbm(f))
        de(f)

        f = n("./f.f")
        with self.assertRaises(EX_NAP):
            wbm(f)

        f = j(dm, "f.md")
        with self.assertRaises(EX_NEF):
            wbm(f)

        f = j(dm, "f.f")
        cr(f, False)
        with self.assertRaises(EX_NEMD):
            wbm(f)
        de(f)
Esempio n. 5
0
    def test_crt_apnm_note(self):
        cn_ = cn(dm)
        put("cn(dm).ap_di", cn_.ap_di)
        put("cn(dm).ap_md", cn_.ap_md)
        put("cn(dm).nm_di", cn_.nm_di)
        put("cn(dm).nm_md", cn_.nm_md)

        d = j(dm, "d")
        cr(d, True)
        with self.assertRaises(EX_DND):
            cn(dm)
        de(d)

        d = j(dm, "d")
        with self.assertRaises(EX_NED):
            cn(d)

        d = n("./")
        with self.assertRaises(EX_NAP):
            cn(d)
Esempio n. 6
0
    def test_chk_exst_md(self):
        self.assertFalse(cm(dm))

        f = j(dm, "f.f")
        cr(f, False)
        self.assertFalse(cm(dm))
        de(f)

        f = j(dm, "j.md")
        cr(f, False)
        self.assertTrue(cm(dm))
        de(f)

        d = n("./")
        with self.assertRaises(EX_NAP):
            cm(d)

        d = j(dm, "d")
        with self.assertRaises(EX_NED):
            cm(d)
Esempio n. 7
0
    def test_rd_md(self):
        f = j(dm, "f.md")
        cr(f, False)
        ls = ["1", "2", "3"]
        am(f, ls)
        put("rd(f)", rd(f))
        de(f)

        f = n("./f.f")
        with self.assertRaises(EX_NAP):
            rd(f)

        f = j(dm, "f.f")
        with self.assertRaises(EX_NEF):
            rd(f)

        f = j(dm, "f.f")
        cr(f, False)
        with self.assertRaises(EX_NEMD):
            rd(f)
        de(f)
Esempio n. 8
0
    def test_chk_md_b(self):
        f = j(dm, "f.md")
        cr(f, False)
        ls = ["1", "2", "3"]
        am(f, ls)
        self.assertFalse(cmb(f))
        de(f)

        f = j(dm, "f.md")
        cr(f, False)
        self.assertTrue(cmb(f))
        de(f)

        f = n("./f.f")
        with self.assertRaises(EX_NAP):
            cmb(f)

        f = j(dm, "f.md")
        with self.assertRaises(EX_NEF):
            cmb(f)

        f = j(dm, "f.f")
        cr(f, False)
        with self.assertRaises(EX_NEMD):
            cmb(f)
        de(f)
Esempio n. 9
0
    def test_get_md(self):
        f = j(dm, "f.md")
        cr(f, False)
        put("gm(dm)", gm(dm))
        de(f)

        f1 = j(dm, "f1.md")
        f2 = j(dm, "f2.md")
        cr(f1, False)
        cr(f2, False)
        with self.assertRaises(EX_EMMD):
            gm(dm)
        de(f1)
        de(f2)

        d = n("./")
        with self.assertRaises(EX_NAP):
            gm(d)

        d = j(dm, "d")
        with self.assertRaises(EX_NED):
            gm(d)

        with self.assertRaises(EX_NEMD):
            gm(dm)
Esempio n. 10
0
    def test_apnd_md(self):
        f = j(dm, "f.md")
        cr(f, False)
        ls = ["1", "2", "3"]
        self.assertTrue(am(f, ls))
        de(f)

        f = j(dm, "f.md")
        cr(f, False)
        lns = [1, "2", "3"]
        with self.assertRaises(EX_LNAS):
            am(f, lns)
        de(f)

        f = n("./f.f")
        ls = ["1", "2", "3"]
        with self.assertRaises(EX_NAP):
            am(f, ls)

        f = j(dm, "f.md")
        ls = ["1", "2", "3"]
        with self.assertRaises(EX_NEF):
            am(f, ls)

        f = j(dm, "f.f")
        ls = ["1", "2", "3"]
        cr(f, False)
        with self.assertRaises(EX_NEMD):
            am(f, ls)
        de(f)
Esempio n. 11
0
 def test_crt(self):
     de(
         dm
     )  # Need to tear down the environment because this test meant to set up the environment.
     for i in edf:
         self.assertTrue(cr(i, True))
     for i in ef:
         self.assertTrue(cr(i, False))
     for i in edf:
         self.assertFalse(cr(i, True))
     for i in ef:
         self.assertFalse(cr(i, False))
     with self.assertRaises(EX_NAP):
         cr(dnr, True)
     with self.assertRaises(EX_NAP):
         cr(fnr, False)
Esempio n. 12
0
 def test_ren(self):
     self.assertTrue(r(dex, dren))
     self.assertTrue(r(fe, fren))
     cr(dex, True)
     cr(fe, False)
     # Re - create.
     self.assertTrue(r(dex, dren))  # Replace.
     self.assertTrue(r(fe, fren))  # Replace.
     cr(dex, True)
     cr(fe, False)
     # Re - create.
     with self.assertRaises(EX_NAP):
         r(dnr, dren)
     with self.assertRaises(EX_NAP):
         r(fnr, fren)
     with self.assertRaises(EX_NDF):
         r(dne, dren)
     with self.assertRaises(EX_NDF):
         r(fne, fren)
Esempio n. 13
0
 def test_mov(self):
     de(dmv2)
     de(fmv2)
     # Delete the move directory 2 and move file 2.
     self.assertTrue(m(dmv1, dmv2))
     cr(dmv1, True)
     # Re - create move directory 1.
     self.assertTrue(m(dmv1, dmv2))
     cr(dmv1, True)
     # Re - create move directory 1 and move directory 1 is replaced.
     self.assertTrue(m(fmv1, fmv2))
     cr(fmv1, False)
     # Re - create move file 1.
     self.assertTrue(m(fmv1, fmv2))
     cr(fmv1, False)
     # Re - create move file 1 and move file 1 is replaced.
     self.assertFalse(m(dmv1, dmv2,
                        False))  # Old move directory 1 is not replaced.
     self.assertFalse(m(fmv1, fmv2,
                        False))  # Old move file 1 is not replaced.
     with self.assertRaises(EX_NAP):
         m(dne, dnr)
     with self.assertRaises(EX_NAP):
         m(dnr, dne)
     with self.assertRaises(EX_NAP):
         m(fne, fnr)
     with self.assertRaises(EX_NAP):
         m(fnr, fne)
     with self.assertRaises(EX_SP):
         m(dex, dex)
     de(dmv1)
     de(fmv1)
     # Delete the move directory 1 and move file 1
     with self.assertRaises(EX_NDF):
         m(dmv1, dmv2)
     with self.assertRaises(EX_NDF):
         m(fmv1, fmv2)
Esempio n. 14
0
 def setUp(self):
     cr(dm, True)
Esempio n. 15
0
 def test_wlk_get_note(self):
     dw = j(dm, "dw")
     cr(dw, True)
     d1 = j(dw, "d1")
     cr(d1, True)
     d2 = j(dw, "d2")
     cr(d2, True)
     d3 = j(dw, "d3")
     cr(d3, True)
     d4 = j(dw, "d4")
     cr(d4, True)
     d5 = j(dw, "d5")
     cr(d5, True)
     f1_1 = j(d1, "f1_1.f")
     cr(f1_1, False)
     f1_2 = j(d1, "f1_2.f")
     cr(f1_2, False)
     f2_1 = j(d2, "f2_1.f")
     cr(f2_1, False)
     f2_2 = j(d2, "f2_2.f")
     cr(f2_2, False)
     f3_1 = j(d3, "f3_1.f")
     cr(f3_1, False)
     f3_2 = j(d3, "f3_2.f")
     cr(f3_2, False)
     f4_1 = j(d4, "f4_1.f")
     cr(f4_1, False)
     f4_2 = j(d4, "f4_2.f")
     cr(f4_2, False)
     f5_1 = j(d5, "f5_1.f")
     cr(f5_1, False)
     f5_2 = j(d5, "f5_2.f")
     cr(f5_2, False)
Esempio n. 16
0
    def test_repair(self):
        d = j(dm, "d")
        cr(d, True)
        fm = j(d, "fm.md")
        cr(fm, False)
        am(fm, var.smpl_md)
        f1 = j(d, "f1.bmp")
        cid(f1)
        f2 = j(d, "f2.jpeg")
        cid(f2)
        f3 = j(d, "f3.jpg")
        cid(f3)
        f4 = j(d, "f4.png")
        cid(f4)
        f5 = j(d, "f5.fi")
        cr(f5, False)
        f6 = j(d, "f6.fi")
        cr(f6, False)
        f7 = j(d, "8.fi")
        cr(f7, False)
        dn = r(d)
        self.assertNotEqual(d, dn)
        de(dn)

        d = j(dm, "20000101-0000-cet-d")
        cr(d, True)
        fm = j(d, "fm.md")
        cr(fm, False)
        am(fm, var.smpl_md_prefix)
        f1 = j(d, "20010101-0000-cet-f1.bmp")
        cid(f1)
        f2 = j(d, "f2.jpeg")
        cid(f2)
        f3 = j(d, "f3.jpg")
        cid(f3)
        f4 = j(d, "f4.png")
        cid(f4)
        f5 = j(d, "f5.fi")
        cr(f5, False)
        f6 = j(d, "f6.fi")
        cr(f6, False)
        f7 = j(d, "8.fi")
        cr(f7, False)
        dn = r(d)
        self.assertEqual(d, dn)
        de(dn)

        d = j(dm, "20010101-0000-cet-d")
        cr(d, True)
        fm = j(d, "20010101-0000-cet-d.md")
        cr(fm, False)
        am(fm, var.smpl_md_correct)
        f1 = j(d, "20010101-0000-cet-1.png")
        cid(f1)
        f2 = j(d, "20010101-0000-cet-2.png")
        cid(f2)
        f3 = j(d, "20010101-0000-cet-3.png")
        cid(f3)
        f4 = j(d, "20010101-0000-cet-4.png")
        cid(f4)
        f5 = j(d, "20010101-0000-cet-5-test.pdf")
        cr(f5, False)
        f6 = j(d, "20010101-0000-cet-6-test.pdf")
        cr(f6, False)
        dn = r(d)
        self.assertEqual(d, dn)
        de(dn)

        f1 = j(dm, "f1.md")
        cr(f1, False)
        f2 = j(dm, "f2.md")
        cr(f2, False)
        with self.assertRaises(EX_EMMD):
            r(dm)
        de(f1)
        de(f2)

        d = j(dm, "d")
        cr(d, True)
        f = j(d, "f.md")
        cr(f, False)
        with self.assertRaises(EX_MDNC):
            r(d)
        de(d)

        d = j(dm, "20000101-0000-cet-d")
        cr(d, True)
        f = j(d, "f.md")
        cr(f, False)
        with self.assertRaises(EX_MDNC):
            r(d)
        de(d)

        d = n("./")
        with self.assertRaises(EX_NAP):
            r(d)

        d = j(dm, "d")
        with self.assertRaises(EX_NED):
            r(d)

        d = j(dm, "d")
        cr(d, True)
        with self.assertRaises(EX_NEMD):
            r(d)
        de(d)
Esempio n. 17
0
 def setUp(self):
     for i in edf:
         cr(i, True)
     for i in ef:
         cr(i, False)
Esempio n. 18
0
    def test_init(self):
        d = j(dm, "d")
        cr(d, True)
        f1 = j(d, "f1.bmp")
        cid(f1)
        f2 = j(d, "f2.jpeg")
        cid(f2)
        f3 = j(d, "f3.jpg")
        cid(f3)
        f4 = j(d, "f4.png")
        cid(f4)
        f5 = j(d, "f5.fi")
        cr(f5, False)
        f6 = j(d, "f6.fi")
        cr(f6, False)
        f7 = j(d, "8.fi")
        cr(f7, False)
        dn = i(d)
        self.assertNotEqual(d, dn)
        de(dn)

        d = j(dm, "20000101-0000-cet-d")
        cr(d, True)
        f1 = j(d, "f1.bmp")
        cid(f1)
        f2 = j(d, "f2.jpeg")
        cid(f2)
        f3 = j(d, "f3.jpg")
        cid(f3)
        f4 = j(d, "f4.png")
        cid(f4)
        f5 = j(d, "f5.fi")
        cr(f5, False)
        f6 = j(d, "f6.fi")
        cr(f6, False)
        f7 = j(d, "8.fi")
        cr(f7, False)
        dn = i(d)
        self.assertEqual(d, dn)
        de(dn)

        d = j(dm, "20010101-0000-cet-d")
        cr(d, True)
        fm = j(d, "20010101-0000-cet-d.md")
        cr(fm, False)
        f1 = j(d, "20010101-0000-cet-1.png")
        cid(f1)
        f2 = j(d, "20010101-0000-cet-2.png")
        cid(f2)
        f3 = j(d, "20010101-0000-cet-3.png")
        cid(f3)
        f4 = j(d, "20010101-0000-cet-4.png")
        cid(f4)
        f5 = j(d, "20010101-0000-cet-5-test.pdf")
        cr(f5, False)
        f6 = j(d, "20010101-0000-cet-6-test.pdf")
        cr(f6, False)
        dn = i(d)
        self.assertEqual(d, dn)
        de(dn)

        f1 = j(dm, "f1.md")
        cr(f1, False)
        f2 = j(dm, "f2.md")
        cr(f2, False)
        with self.assertRaises(EX_EMMD):
            i(dm)
        de(f1)
        de(f2)

        d = j(dm, "d")
        cr(d, True)
        f = j(d, "f.md")
        cr(f, False)
        ls = ["1", "2", "3"]
        am(f, ls)
        with self.assertRaises(EX_MDC):
            i(d)
        de(d)

        d = j(dm, "20000101-0000-cet-d")
        cr(d, True)
        f = j(d, "f.md")
        cr(f, False)
        ls = ["1", "2", "3"]
        am(f, ls)
        with self.assertRaises(EX_MDC):
            i(d)
        de(d)

        d = n("./")
        with self.assertRaises(EX_NAP):
            i(d)

        d = j(dm, "d")
        with self.assertRaises(EX_NED):
            i(d)
Esempio n. 19
0
    def test_crt_apnm_img_cnvrt(self):
        f = j(dm, "f.bmp")
        cid(f)
        cni_ = cc(f)
        put("cc(f).ap_bak", cni_.ap_bak)
        put("cc(f).ap_cn", cni_.ap_cn)
        put("cc(f).nm_bak", cni_.nm_bak)
        put("cc(f).nm_cn", cni_.nm_cn)
        de(f)

        f = j(dm, "f.jpeg")
        cid(f)
        cni_ = cc(f)
        put("cc(f).ap_bak", cni_.ap_bak)
        put("cc(f).ap_cn", cni_.ap_cn)
        put("cc(f).nm_bak", cni_.nm_bak)
        put("cc(f).nm_cn", cni_.nm_cn)
        de(f)

        f = j(dm, "f.jpg")
        cid(f)
        cni_ = cc(f)
        put("cc(f).ap_bak", cni_.ap_bak)
        put("cc(f).ap_cn", cni_.ap_cn)
        put("cc(f).nm_bak", cni_.nm_bak)
        put("cc(f).nm_cn", cni_.nm_cn)
        de(f)

        f = j(dm, "f.png")
        cid(f)
        cni_ = cc(f)
        put("cc(f).ap_bak", cni_.ap_bak)
        put("cc(f).ap_cn", cni_.ap_cn)
        put("cc(f).nm_bak", cni_.nm_bak)
        put("cc(f).nm_cn", cni_.nm_cn)
        de(f)

        f = n("./f.f")
        with self.assertRaises(EX_NAP):
            cc(f)

        f = j(dm, "f.bmp")
        with self.assertRaises(EX_NEF):
            cc(f)

        f = j(dm, "f.jpeg")
        with self.assertRaises(EX_NEF):
            cc(f)

        f = j(dm, "f.jpg")
        with self.assertRaises(EX_NEF):
            cc(f)

        f = j(dm, "f.png")
        with self.assertRaises(EX_NEF):
            cc(f)

        f = j(dm, "f.f")
        cr(f, False)
        with self.assertRaises(EX_NIMG):
            cc(f)
        de(f)
Esempio n. 20
0
    def test_get_lst_n_md(self):
        f1 = j(dm, "f1.md")
        cr(f1, False)
        f2 = j(dm, "f2.f")
        cr(f2, False)
        f3 = j(dm, "f3.f")
        cr(f3, False)
        put("glnm(dm)", glnm(dm))
        de(f1)
        de(f2)
        de(f3)

        d = j(dm, "d")
        cr(d, True)
        with self.assertRaises(EX_DND):
            glnm(dm)
        de(d)

        f1 = j(dm, "f1.md")
        cr(f1, False)
        f2 = j(dm, "f2.md")
        cr(f2, False)
        with self.assertRaises(EX_EMMD):
            glnm(dm)
        de(f1)
        de(f2)

        d = n("./")
        with self.assertRaises(EX_NAP):
            glnm(d)

        d = j(dm, "d")
        with self.assertRaises(EX_NED):
            glnm(d)