<commit_before>from datetime import datetime
import os

__author__ = 'ross'
from pychron.core.ui import set_qt

set_qt()

import unittest
from pychron.entry.loaders.analysis_loader import XLSAnalysisLoader


class XLSAnalysisLoaderTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.loader = XLSAnalysisLoader()
        p = 'pychron/entry/tests/data/analysis_import.xls'
        if not os.path.isfile(p):
            p = './data/analysis_import.xls'
        cls.loader.load_analyses(p)

    def test_identifier1(self):
        self._test_attr(0, 'get_identifier', '12345')

    def test_identifier2(self):
        self._test_attr(1, 'get_identifier', '12346')

    def test_project(self):
        self._test_attr(0, 'get_project', 'foo')

    def test_sample(self):
        self._test_attr(0, 'get_sample', 'bar')

    def test_material(self):
        self._test_attr(0, 'get_material', 'bat')

    def test_aliquot(self):
        self._test_attr(0, 'get_aliquot', 1)

    def test_step(self):
        self._test_attr(0, 'get_step', 'A')

    def test_analysis_time(self):
        self._test_attr(0, 'get_analysis_time', datetime(2012, 6, 7, 0, 0))

    def test_ar401(self):
        v = self.loader.get_isotope(0, 'Ar40')
        self.assertEqual(v, 'Sheet2')

    def test_ar402(self):
        v = self.loader.get_isotope(1, 'Ar40')
        self.assertEqual(v, 10)

    # def test_ar401_raw(self):
    # xs, ys = self.loader.get_isotope_data(0, 'Ar40')
    #     self.assertListEqual(xs, [1, 2, 3, 4, 5])
    #     self.assertListEqual(ys, [499, 498, 497, 496, 495])

    def test_ar402_raw(self):
        xs, ys = self.loader.get_isotope_data(1, 'Ar40')
        self.assertListEqual(xs, [])
        self.assertListEqual(ys, [])
    #
    # def test_ar391_raw(self):
    #     xs, ys = self.loader.get_isotope_data(0, 'Ar39')
    #     self.assertListEqual(xs, [1, 2, 3, 4, 5])
    #     self.assertListEqual(ys, [49, 48, 47, 46, 45])

    def _test_attr(self, idx, funcname, value):
        func = getattr(self.loader, funcname)
        self.assertEqual(func(idx), value)


if __name__ == '__main__':
    unittest.main()<commit_msg>tweaked analysis_loader tests<commit_after>from datetime import datetime
import os

__author__ = 'ross'
from pychron.core.ui import set_qt

set_qt()

import unittest
from pychron.entry.loaders.analysis_loader import XLSAnalysisLoader


class XLSAnalysisLoaderTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.loader = XLSAnalysisLoader()
        p = 'pychron/entry/tests/data/analysis_import.xls'
        if not os.path.isfile(p):
            p = './data/analysis_import.xls'
        cls.loader.load_analyses(p)

    def test_identifier1(self):
        self._test_attr(0, 'get_identifier', '12345')

    def test_identifier2(self):
        self._test_attr(1, 'get_identifier', '12346')

    def test_project(self):
        self._test_attr(0, 'get_project', 'foo')

    def test_sample(self):
        self._test_attr(0, 'get_sample', 'bar')

    def test_material(self):
        self._test_attr(0, 'get_material', 'bat')

    def test_aliquot(self):
        self._test_attr(0, 'get_aliquot', 1)

    def test_step(self):
        self._test_attr(0, 'get_step', 'A')

    def test_analysis_time(self):
        self._test_attr(0, 'get_analysis_time', datetime(2012, 6, 7, 0, 0))

    def test_ar401(self):
        v = self.loader.get_isotope(0, 'Ar40')
        self.assertEqual(v, 'Sheet2')

    def test_ar402(self):
        v = self.loader.get_isotope(1, 'Ar40')
        self.assertEqual(v, 10)

    def test_ar401_raw(self):
        xs, ys = self.loader.get_isotope_data(0, 'Ar40')
        self.assertListEqual(xs, [1, 2, 3, 4, 5])
        self.assertListEqual(ys, [499, 498, 497, 496, 495])

    def test_ar402_raw(self):
        xs, ys = self.loader.get_isotope_data(1, 'Ar40')
        self.assertListEqual(xs, [])
        self.assertListEqual(ys, [])

    def test_ar391_raw(self):
        xs, ys = self.loader.get_isotope_data(0, 'Ar39')
        self.assertListEqual(xs, [1, 2, 3, 4, 5])
        self.assertListEqual(ys, [49, 48, 47, 46, 45])

    def _test_attr(self, idx, funcname, value):
        func = getattr(self.loader, funcname)
        self.assertEqual(func(idx), value)


if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.1369198799353498, 'fraction_numerical': 0.04479335026552759, 'mean_word_length': 3.0599812558575445, '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': '4808750', 'n_tokens_mistral': 1730, 'n_tokens_neox': 1542, 'n_words': 301}