<commit_before># -*- coding: utf-8 -*-
from destral import testing
from destral.transaction import Transaction
from destral.patch import PatchNewCursors
import netsvc
import time
import random


class EmissionTests(testing.OOTestCase):
    def test_change_emission_state(self):
        """
        Checks if when state changed, everithing works
        :return:
        """
        pool = self.openerp.pool
        emission_obj = pool.get('generationkwh.emission')
        imd_obj = pool.get('ir.model.data')

        with Transaction().start(self.database) as txn:
            cursor = txn.cursor
            uid = txn.user
            em_id = imd_obj.get_object_reference(
                cursor, uid, 'som_generationkwh', 'emissio_0001')[1]
            em_0001 = emission_obj.browse(cursor, uid, em_id)

            emission_obj.action_open(cursor, uid, em_id)

            self.assertEquals(em_0001.state, "open")


# vim: et ts=4 sw=4<commit_msg>New test set_done and configure setUp and tearDown<commit_after># -*- coding: utf-8 -*-
from destral import testing
from destral.transaction import Transaction
from destral.patch import PatchNewCursors
import netsvc
import time
import random


class EmissionTests(testing.OOTestCase):
    def setUp(self):
        self.pool = self.openerp.pool
        self.imd_obj = self.pool.get('ir.model.data')
        self.emission_obj = self.pool.get('generationkwh.emission')
        #self.txn = Transaction().start(self.database)

    def tearDown(self):
        #self.txn.stop()
        pass

    def test__action_open(self):
        """
        Checks if when state changed, everithing works
        :return:
        """
        with Transaction().start(self.database) as txn:
            cursor = txn.cursor
            uid = txn.user
            em_id = self.imd_obj.get_object_reference(
                cursor, uid, 'som_generationkwh', 'emissio_0001')[1]
            em_0001 = self.emission_obj.browse(cursor, uid, em_id)

            self.emission_obj.action_open(cursor, uid, em_id)

            self.assertEquals(em_0001.state, "open")

    def test__set_done(self):
        """
        Checks if when state changed, everithing works
        :return:
        """
        with Transaction().start(self.database) as txn:
            cursor = txn.cursor
            uid = txn.user
            em_id = self.imd_obj.get_object_reference(
                cursor, uid, 'som_generationkwh', 'emissio_0001')[1]
            em_0001 = self.emission_obj.browse(cursor, uid, em_id)

            self.emission_obj.set_done(cursor, uid, em_id)

            self.assertEquals(em_0001.state, "done")

# vim: et ts=4 sw=4
{'fraction_non_alphanumeric': 0.10282485875706214, 'fraction_numerical': 0.01694915254237288, 'mean_word_length': 2.422680412371134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7577208', 'n_tokens_mistral': 866, 'n_tokens_neox': 806, 'n_words': 179}