Beispiel #1
0
 def test_dbremove_ruleset(self):
     uniargs_add = [u"testmmąöî", u"mmąöî2", u"fake@mmąöî", u"mmąöî", \
                 u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî"]
     dgm_cli.dbadd(self.db, self.config, uniargs_add)
     uniargs = [u"-E", u"testmmąöî"]
     dgm_cli.dbremove(self.db, self.config, uniargs)
     assert os.path.exists(TESTFILE) #it's not a bug, it's a feature...
     with open(TESTFILE) as f1:
         assert f1.read() == ""
Beispiel #2
0
 def test_dbadd_create_ruleset(self):
     uniargs = [u"mmąöî666", u"mmąöî", u"fake@mmąöî", u"mmąöî", u"mmąöî", \
                 u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî"]
     dgm_cli.dbadd(self.db, self.config, uniargs)
     filepath = os.path.join(BASEDIR, u"mmąöî666.rs")
     assert os.path.exists(filepath)
     with open(filepath) as f1:
         with open(TESTFILE) as f2:
             assert f1.read() == f2.read()
Beispiel #3
0
    def test_dbupdate_deps(self):
        # Add a rule that depends on the one in the test file (mmąöî)
        uniargs_add = [u"testmmąöî", u"mmąöî2", u"fake@mmąöî", u"mmąöî", \
                    u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî"]
        dgm_cli.dbadd(self.db, self.config, uniargs_add)

        # Update the name of the first one and update references
        uniargs = [u"testmmąöî", u"mmąöî", u"name=updatemmąöî"]
        dgm_cli.dbupdate(self.db, self.config, uniargs)
        assert not fetch_and_check(TESTFILE, u"mmąöî", "help", u"mmąöî")
        assert fetch_and_check(TESTFILE, u"updatemmąöî", "help", u"mmąöî")
        assert fetch_and_check(TESTFILE, u"mmąöî2", "dependson", u"updatemmąöî")
Beispiel #4
0
 def test_dbadd_nocreate(self):
     uniargs = [u"testmmąöî", u"mmąöîname", u"fake@mmąöîtype", \
                 u"mmąöîfilter", u"mmąöîaction", u"mmąöîdeps", \
                 u"mmąöîdepends", u"mmąöîcomments", u"mmąöîhelp"]
     dgm_cli.dbadd(self.db, self.config, uniargs)
     assert os.path.exists(TESTFILE)
     assert fetch_and_check(TESTFILE, u"mmąöîname", "types", u"fake@mmąöîtype")
     assert fetch_and_check(TESTFILE, u"mmąöîname", "filter", u"mmąöîfilter")
     assert fetch_and_check(TESTFILE, u"mmąöîname", "action", u"mmąöîaction")
     assert fetch_and_check(TESTFILE, u"mmąöîname", "depsfinder", u"mmąöîdeps")
     assert fetch_and_check(TESTFILE, u"mmąöîname", "dependson", u"mmąöîdepends")
     assert fetch_and_check(TESTFILE, u"mmąöîname", "comments", u"mmąöîcomments")
     assert fetch_and_check(TESTFILE, u"mmąöîname", "help", u"mmąöîhelp")
Beispiel #5
0
    def test_graphrules_file_2rules(self):
        # Add a rule that depends on the one in the test file (mmąöî)
        uniargs_add = [u"testmmąöî", u"mmąöî2", u"fake@mmąöî", u"mmąöî", \
                    u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî"]
        dgm_cli.dbadd(self.db, self.config, uniargs_add)

        pathgraph = os.path.join(BASEDIR, u"mmąöîgraph")
        uniargs = [u"--out="+pathgraph, u"testmmąöî"]
        dgm_cli.graphrules(self.db, self.config, uniargs)
        assert os.path.exists(pathgraph)
        with open(pathgraph) as f1:
            f1r = f1.read().decode('utf-8')
            val = compare_to_ref("test_graphrules_file_2rules", "graph")
            assert val == f1r
Beispiel #6
0
    def test_graphrules_nofile_2rules(self):
        # Add a rule that depends on the one in the test file (mmąöî)
        uniargs_add = [u"testmmąöî", u"mmąöî2", u"fake@mmąöî", u"mmąöî", \
                    u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî"]
        dgm_cli.dbadd(self.db, self.config, uniargs_add)

        uniargs = [u"testmmąöî"]
        # The graph is sent to output using logger.output()
        capturer = Capturer(self.logger)
        dgm_cli.graphrules(self.db, self.config, uniargs)
        data = capturer.getCaptured().decode('utf-8')

        val = compare_to_ref("test_graphrules_nofile_2rules", "graph")
        assert data == val
Beispiel #7
0
    def test_dbupdate_nodeps(self):
        # Add a rule that depends on the one in the test file (mmąöî)
        uniargs_add = [u"testmmąöî", u"mmąöî2", u"fake@mmąöî", u"mmąöî", \
                    u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî"]
        dgm_cli.dbadd(self.db, self.config, uniargs_add)

        # Update the name of the first one and don't update references
        uniargs = [u"--nodeps", u"testmmąöî", u"mmąöî", u"name=updatemmąöî"]
        dgm_cli.dbupdate(self.db, self.config, uniargs)
        # TODO is this a bug? cf dgm.model:312. The tests should be:
        #assert not fetch_and_check(TESTFILE, u"mmąöî", "help", u"mmąöî")
        #assert fetch_and_check(TESTFILE, u"updatemmąöî", "help", u"mmąöî")
        #assert fetch_and_check(TESTFILE, u"mmąöî2", "dependson", u"mmąöî")
        assert fetch_and_check(TESTFILE, u"mmąöî", "help", u"mmąöî")
        assert fetch_and_check(TESTFILE, u"mmąöî2", "dependson", u"mmąöî")
Beispiel #8
0
 def test_dbcopy_ruleset_nocreate(self):
     # Create a second rs
     uniargs_add = [u"mmąöî666", u"mmąöî", u"fake@mmąöî", u"mmąöî", u"mmąöî", \
                 u"mmąöî", u"mmąöî", u"mmąöî", u"mmąöî"]
     dgm_cli.dbadd(self.db, self.config, uniargs_add)
     # Empty second rs
     uniargs_rem = [u"-E", u"mmąöî666"]
     dgm_cli.dbremove(self.db, self.config, uniargs_rem)
     filepath = os.path.join(BASEDIR, u"mmąöî666.rs")
     # Test if still here and empty
     assert os.path.exists(filepath)
     with open(filepath) as f1:
          assert f1.read() == ""
     # Copy from test to second rs 
     uniargs = [u"testmmąöî", u"mmąöî666"]
     dgm_cli.dbcopy(self.db, self.config, uniargs)
     with open(filepath) as f1:
         with open(TESTFILE) as f2:
             assert f1.read() == f2.read()